<template>
  <div class="main">
    <el-container class="layout-container">
      <!-- 这边的宽度不能写死，要随着展开折叠改变 -->
      <el-aside :width="collapseState ? '60px' : '210px'" class="aside">
        <MainNav :collapseState="collapseState" />
      </el-aside>
      <el-container>
        <el-header height="50px">
          <MainHeader @collapseChange="handCollapse" />
        </el-header>
        <!-- 二级路由，左侧nav切换,展示不同的页面 -->
        <el-main><router-view></router-view></el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script setup lang="ts">
import MainNav from '@/components/main-nav/main-nav.vue'
import MainHeader from '@/components/main-header/main-header.vue'
import { ref } from 'vue'

const collapseState = ref(false)
function handCollapse(val: boolean) {
  console.log('父组件', val)

  collapseState.value = val
}
</script>

<style scoped lang="less">
.main {
  height: 100%;
  .layout-container {
    height: 100%;

    .el-aside {
      overflow-x: hidden;
      overflow-y: auto;
      line-height: 200px;
      text-align: left;
      cursor: pointer;
      background-color: #001529;
      transition: width 0.3s linear; // 宽度变化时的动画
      scrollbar-width: none;
      -ms-overflow-style: none;
      &::-webkit-scrollbar {
        display: none;
      }
    }
  }
}
</style>
